#include<bits/stdc++.h>
#define int long long
using namespace std;
namespace IO
{
	template<typename T>
	void read(T &_x){_x=0;int _f=1;char ch=getchar();while(!isdigit(ch)) _f=(ch=='-'?-1:_f),ch=getchar();while(isdigit(ch)) _x=_x*10+(ch^48),ch=getchar();_x*=_f;}
	template<typename T,typename... Args>
	void read(T &_x,Args&...others){Read(_x);Read(others...);}
	const int BUF=20000000;char buf[BUF],top,stk[32];int plen;
	#define pc(x) buf[plen++]=x
	#define flush(); fwrite(buf,1,plen,stdout),plen=0;
	template<typename T>inline void print(T x){if(!x){pc(48);return;}if(x<0) x=-x,pc('-');for(;x;x/=10) stk[++top]=48+x%10;while(top) pc(stk[top--]);}
}
using namespace IO;
const int N = 1e5+10,M = 1e6+10,mod = 99844353,mod1 = 23333,mod2 = 233333,mod3 = 23333,mod4 = 23331,mod5 = 813333;
int n,a[N],b[N],ha[N],ans,v[M],sum,sum1,l;
void dfs(int x)
{
	if(x > n)
	{
		sum = sum1 = 1;
		for(int i = 1;i <= n;i++) sum1 = (sum1*mod1%mod2+b[i])%mod2,sum1 = (sum1*mod4%mod5+b[i]*mod3)%mod5;
		if(v[sum1]) return;
		v[sum1] = 1;
		for(int i = 1;i <= n;i++) sum = (sum*b[i])%mod;
		ans += sum; if(ans > mod) ans -= mod;
		return;
	}
	for(int i = 0;i <= a[x];i++) b[x] -= i,b[x%n+1] += i,dfs(x+1),b[x%n+1] -= i,b[x] += i;
}
signed main()
{
	freopen("trade.in","r",stdin);
	freopen("trade.out","w",stdout);	
	read(n);
	for(int i = 1;i <= n;i++)
	{
		read(a[i]),b[i] = a[i];
		if(a[i] > 1) l = 1;
	}
	if(l == 0)
	{
		l = 1;
		for(int i = 1;i <= n;i++)
			if(a[i] == 0)
			{
				l = 0;
				break;
			}
		if(l == 1) ans = 1;
		print(ans); flush();
		return 0;
	}
	dfs(1);
	print(ans); flush();
	return 0;
}
/*
5
11 12 9 6 5
*/
